package sort.impl;

import anaydis.sort.SorterType;
import com.sun.istack.internal.NotNull;

import java.util.Comparator;
import java.util.List;

public class BubbleSorter extends AbstractSorter {

    public BubbleSorter() {
        super(SorterType.BUBBLE);
    }

    public <T> void sort(@NotNull Comparator<T> tComparator, @NotNull List<T> ts) {
        int cont = -1;
        int j = 0;
        while(j<ts.size()&&cont!=0){
            cont = 0;
            for(int i =0; i < ts.size()-1-j;i++){
                if(greater(tComparator,ts,i,i+1)){
                    swap(ts,i,i+1);
                    cont++;
                }
            }
            j++;            
        }
    }


}
